home *** CD-ROM | disk | FTP | other *** search
- Path: s02.pavilion.co.uk!usenet
- From: AJRobb@pavilion.co.uk (Andy J Robb)
- Newsgroups: comp.lang.c
- Subject: Re: strange behaviour of doubles
- Date: Tue, 05 Mar 1996 02:55:28 GMT
- Organization: Pavilion Internet plc
- Message-ID: <4hgadl$275@s02.pavilion.co.uk>
- References: <1996Mar4.014052.6236@dcs.warwick.ac.uk>
- NNTP-Posting-Host: poolc35.pavilion.co.uk
- X-Newsreader: Forte Free Agent 1.0.82
-
- D.C.Molero@dcs.warwick.ac.uk (Daniel Castillo Molero) wrote:
-
-
- >Dear readers,
- >Can anybody explain to me why the behaviour of the following little
- >program is not the expected one ??
- >It is supposed to read from std input pairs of doubles and print them,
- >until 0.0 is input.
- >The strange thing is that it doesn't print the input number, e.g. when
- >I input 1.0 1.0 it prints 0.0078125 0.0078125
- >I will appreciate very much any help.
-
- You need to use "%lg" to scan into a double.
-
- >#include <stdio.h>
- >#include <stdlib.h>
-
- >main() {
- >double x, y;
- >scanf("%g", &x);
- >while (x != 0.0) {
- > scanf("%g", &y);
- > printf("%g %g\n", x, y);
- > scanf("%g", &x);
- >}
- >return(0);
- >}
- >--
- >* Daniel Castillo. danmol@dcs.warwick.ac.uk *
-
-
-
- -----BEGIN PGP PUBLIC KEY BLOCK-----
- Version: 2.6.2i
-
- mQCNAy/MpRwAAAEEAOt6uBYqT8yv9EmqNhK8m6v+bYi8QjnGW3Bo6iU1gsMj5pa6
- MHgq99c8deADbE3cbJ6uZS9v5pZE3WCf6HCQjlB5iULA5RZzMdAumd/WUzuL9UT3
- B44D9EqqFIL79FlYb56v4oKFqFp1/J2bIpYUwnUvabGzGjdLrpPl4P16x9sNAAUR
- tCNBbmR5IEogUm9iYiA8QUpSb2JiQHBhdmlsaW9uLmNvLnVrPrQhQW5keSBSb2Ji
- IDxBSlJvYmJAcGF2aWxpb24uY28udWs+
- =/wVD
- -----END PGP PUBLIC KEY BLOCK-----
-
-